package com.zhaocaimao.framework.common.validator;


import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

/**
 * 手机号码自定义校验类
 * @author: zhaobin
 * @date: 2025-09-11 18:07:39
 */
public class PhoneNumberValidator implements ConstraintValidator<PhoneNumber, String> {

    @Override
    public boolean isValid(String phoneNumber, ConstraintValidatorContext context) {
        // 校验逻辑：正则表达式判断手机号是否为 11 位数字
        return phoneNumber != null && phoneNumber.matches("\\d{11}");
    }

    @Override
    public void initialize(PhoneNumber constraintAnnotation) {

    }
}
